import java.util.Scanner;

public class Text1 {
    public static boolean dictionary(String[] arg) {
        for (int i = 0; i < arg.length - 1; i++) {
            if(arg[i].compareTo(arg[i+1]) > 0){
                return false;
            }
        }
        return true;
    }
    public static boolean lenth(String[] str) {
        for(int i= 0; i<str.length-1; i++){
            if(str[i].length() >  str[i+1].length()){
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        String[] array = new String[num];
        for (int i = 0; i < num; i++) {
            array[i] = in.next();
        }
        boolean b1 = lenth(array);
        boolean b2 = dictionary(array);
        if (b1 && b2) {
            System.out.println("both");
        } else if (b1 == true) {
            System.out.println("lengths");
        } else if (b2 == true) {
            System.out.println("lexicographically");
        } else System.out.println("none");
    }
    
}